#ifndef TCP_HEADERS
#define TCP_HEADERS
#include <sys/types.h>
#endif

#include <stdint.h>
#include <map>


/* HEADER TYPES */
#define LOW_LEVEL_INI 1
#define LOW_LEVEL_ACK 2
#define STATISITC 3
#define BURST_READY 4



/* ATTRIBUTE TYPES */
#define STATISTIC_DATA 1
#define BURST_TIME 2
#define ROUND_TIME 3
#define RAW_PORT 4
#define ACK 5


struct HDR{
       uint16_t type;
       uint16_t length;     
}      __attribute__ ((packed));

struct attr_hdr{
       uint16_t type;
       uint16_t length;
}
__attribute__((packed));

struct attrs {
       struct attr_hdr* hdr;
       char* message;
       uint16_t message_length;
};

struct List {
	struct attrs attributes;
	struct List* next;
};

struct Packet {
	struct HDR* header;
	struct List* attr_list;
};

struct buffer {
	char * mem;
	uint32_t size;
};

Packet build_packet(int hdr_type, int attr_type, char * input);
Packet build_packet(int hdr_type, int attr_type1, char * input1, int attr_type2, char * input2);
Packet build_statistic_list(std::map<int, char*> statistic_data);
struct buffer encode(struct Packet p);
char* getmessage(char* sock_message);
char* getnextmessage(char* sock_message);
int gettype(char* sock_message);
std::map<int,char*> get_statistic_data_list(char* sock_message);
